package com.example.demo;

import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
    private WebView my_webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        my_webView = findViewById(R.id.my_webView);
  /*      my_webView.loadUrl("http://ica.gdcp.cn/web/loadWebPage.do?1_740_44015038150_3");*/

        my_webView.loadUrl("file:///android_asset/test.html");




        my_webView.setWebViewClient(new WebViewClient(){

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                my_webView.loadUrl(url);
                return true;
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                Log.e("MainActivity","开始加载");
                super.onPageStarted(view, url, favicon);
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                Log.e("MainActivity","结束加载");
                super.onPageFinished(view, url);
            }
        });

    }

    @Override
    public void onBackPressed() {

        if (my_webView.canGoBack()){
            my_webView.goBack();
        }
        else {
            super.onBackPressed();
    }
    }
}
